import fs from 'fs'
import path from 'path'


class FileMethod {
     static fileDel(oldPath: string) {
        return new Promise((resolve, reject) => {
            if (oldPath) {
                fs.unlink(path.resolve(__dirname, `../public/${oldPath}`), (error) => {
                    error ? reject(error) : resolve({ code: 200, data: { msg: '删除成功' } })
                })
            } else {
                resolve({ code: 200, data: { msg: '删除成功' } })
            }
        })
    }
}


export default FileMethod